package cn.bdqn.hospital.dao.impl;

import cn.bdqn.hospital.dao.OrderAllDao;
import cn.bdqn.hospital.entity.OrderAll;
import cn.bdqn.hospital.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;
import java.util.List;

/**
 * 订单总表到层实现类
 */
public class OrderAllDaoImp implements OrderAllDao {

    QueryRunner queryRunner = new QueryRunner();

    /**
     * 新增订单总表
     *
     * @param orderAll
     * @return
     * @throws SQLException
     */
    @Override
    public int add(OrderAll orderAll) throws SQLException {
        int num = 0;
        try{
            String sql = "INSERT INTO orderall(dateNo, money, ygId , hzId) VALUES(?, ?, ?, ?);";
            Object[] objects = new Object[]{orderAll.getDateNo(), orderAll.getMoney(), orderAll.getYgId(), orderAll.getHzId()};
            num = queryRunner.update(DruidUtils.getConnection(), sql, objects);
        }catch (SQLException e){
            e.printStackTrace();
        }
        return num;
    }

    /**
     * 修改订单总表
     *
     * @return
     * @throws SQLException
     */
    @Override
    public int update() throws SQLException {
        return 0;
    }

    /**
     * 通过订单id删除订单
     *
     * @param ddId
     * @return
     * @throws SQLException
     */
    @Override
    public int delete(Integer ddId) throws SQLException {
        return 0;
    }

    /**
     * 分页查询所有订单总单
     *
     * @param pageNo
     * @param pageSize
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderAll> getAll(Integer pageNo, Integer pageSize) throws SQLException {
        return null;
    }

    /**
     * 通过患者id分页查询订单总表
     *
     * @param haId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderAll> getOrderAllByHzId(Integer haId, Integer pageNo, Integer pageSize) throws SQLException {
        return null;
    }

    /**
     * 通过医生id查询订单总表
     *
     * @param yhId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws SQLException
     */
    @Override
    public List<OrderAll> getOrderAllByYgId(Integer yhId, Integer pageNo, Integer pageSize) throws SQLException {
        return null;
    }

    /**
     * 通过id查询订单
     *
     * @param ddzId
     * @return
     * @throws SQLException
     */
    @Override
    public OrderAll getOrderAllInfoByNid(Integer ddzId) throws SQLException {
        return null;
    }
}
